import VueRouter from 'vue-router';

const routes = [
    {
        path: '/',
        name: 'login',
        component: () => import('../components/Login')
    },
    {
        path: '/Index',
        name: 'index',
        component: () => import('../components/Index'),
        children: [
            {
                path: '/Home',
                name: 'home',
                meta: {
                    title: '个人中心'
                },
                component: () => import('../components/Home')
            },
            /*{
                path: '/Sec',
                name: 'sec',
                meta: {
                    title: '支委管理'
                },
                component: () => import('../components/sec/SecManage.vue')
            },
            {
                path: '/Meb',
                name: 'meb',
                meta: {
                    title: '支部成员'
                },
                component: () => import('../components/meb/MebManage.vue')
            },
            {
                path: '/Ogn',
                name: 'ogn',
                meta: {
                    title: '组织管理'
                },
                component: () => import('../components/ogn/OgnManage.vue')
            },
            {
                path: '/Trans',
                name: 'trans',
                meta: {
                    title: '关系转接'
                },
                component: () => import('../components/trans/TransManage.vue')
            },
            {
                path: '/Develp',
                name: 'develp',
                meta: {
                    title: '入党发展'
                },
                component: () => import('../components/develp/DevelpManage.vue')
            },
            {
                path: '/Life',
                name: 'life',
                meta: {
                    title: '组织生活'
                },
                component: () => import('../components/life/LifeManage.vue')
            },
            {
                path: '/MyNews',
                name: 'myNews',
                meta: {
                    title: '组织新闻'
                },
                component: () => import('../components/myNews/MyNewsManage.vue')
            },*/
        ]
    }
]

const router = new VueRouter({
    mode: 'history',
    routes
});

export function resetRouter() {
    router.matcher = new VueRouter({
        mode: 'history',
        routes: []
    }).matcher
}

const VueRouterPush = VueRouter.prototype.push;
VueRouter.prototype.push = function push(to) {
    return VueRouterPush.call(this, to).catch(err => err)
};

export default router;